package com.ftqh.tutorial.consumer;

import lombok.extern.java.Log;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.cloud.stream.messaging.Processor;

/**
 * Created by Administrator on 2017/5/26.
 */
@Log
@EnableBinding(Processor.class)
public class SinkReceiver {
    @StreamListener(Processor.INPUT)
    public void receive(Object payload){
        log.info("Received: "+payload+ " on output channel");
    }
//    public void receive(Message<?> message){
//        System.out.println("Received: "+message.getPayload().toString());
//        log.info("Received: "+message.getPayload().toString());
//    }
    @StreamListener(Processor.OUTPUT)
    public void logSource(OutTimeInfo outTimeInfo) {
        log.info("Received: " + outTimeInfo.toString() + " on output channel");
    }

    public static class OutTimeInfo{

        private String time;
        private String label;

        public String getTime() {
            return time;
        }

        public void setTime(String time) {
            this.time = time;
        }

        public void setSinkLabel(String label) {
            this.label = label;
        }

        public String getLabel() {
            return label;
        }

        @Override
        public String toString() {
            return "SinkTimeInfo [time=" + time + ", label=" + label + "]";
        }

    }
}
